<?php $this->load->view('_inc/header')?>
<script>
$(document).ready(function(){
    $('.cadastrar').click(function(){
        var divEditar = $('.popUp');
        $.ajax({
            url: '<?php echo base_url()?>index.php/parada/cadastrarParada',
            type: 'POST',
            success: function(data){
                divEditar.html(data);
                abrePopUp();
            }
        });
    });
    
    $('.editar').click(function(){
        var id = $(this).attr('id');
        var divEditar = $('.popUp');
        $.ajax({
            url: '<?php echo base_url()?>index.php/parada/editarParada/' + id,
            type: 'POST',
            success: function(data){
                divEditar.html(data);
                abrePopUp();
            }
        });
    });
});
</script>
<h1>Paradas de Ônibus</h1>

<button class="cadastrar">Nova Parada</button>

<table class="listagem">
    <tr>
        <th>Nome</th>
        <th>Cidade</th>
        <th>Endereço</th>
    </tr>
    <?php foreach($paradas as $parada){ ?>
    <tr>
        <td><?php echo $parada->parada?></td>
        <td><?php echo $parada->cidade?></td>
        <td><?php echo $parada->endereco?></td>
        <td><a class="icone editar" id="<?php echo $parada->id?>"></a></td>
        <td><a class="icone excluir" id="<?php echo $parada->id?>"></a></td>
    </tr>
    <?php } ?>
</table>

<?php $this->load->view('_inc/footer')?>